import express from 'express';
import * as marketPriceController from './marketPrice.controller';
import { fileInterceptor, fileProcessor } from './marketPrice.middleware';
import { validateLoginData, authGuard, userGuard } from '../auth/auth.middleware';

const router = express.Router();

/**
 * 获取内容
 */
router.get('/marketPrice', userGuard, marketPriceController.index);

/**
 * 获取内容(按 ID)
 */
router.get('/marketPrice/:postId', userGuard, marketPriceController.marketPriceDetail);

/**
 * 按关键字查询（模糊查询）
 */
router.get('/getMarketPriceByKey', marketPriceController.selectByKey);

/**
 * 创建内容
 */
router.post('/marketPrice', authGuard, marketPriceController.store);

/**
 * 更新内容
 */
router.patch('/marketPrice/:postId', marketPriceController.update)

/**
 * 删除内容
 */
router.delete('/marketPrice/:postId', authGuard, marketPriceController.destroy);
// router.post('/marketPriceDestroy', authGuard, marketPriceController.destroy);
router.post('/marketPriceDestroy', marketPriceController.destroy);

/**
 * 修改状态
 */
router.patch('/marketPriceStatus', authGuard, marketPriceController.status);

/**
 * 上传文件
 */
router.post('/marketPriceFiles', authGuard, fileInterceptor, fileProcessor, marketPriceController.uploads);

/**
 * 文件服务
 */
router.get('/marketPriceFiles/:fileId/serve', marketPriceController.serve);

/**
 * 获取文件 ID
 */
router.post('/getMarketPriceFilesId', marketPriceController.getFileName)

/**
 * 导出路由
 */
export default router;
